package com.edu.exam.entity.quality.monitoring;

import com.edu.exam.enums.AvailabilityStatus;
import com.edu.exam.enums.quality.monitoring.ExperienceLevel;
import com.edu.exam.enums.quality.monitoring.GraderStatus;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.time.LocalDateTime;

/**
 * 批阅人员实体类
 *
 * 根据E-06-01任务分配子模块设计实现
 * 对应grader数据表，用于存储批阅人员的基本信息和能力配置
 *
 * @author System
 * @version 1.0.0
 */
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@EqualsAndHashCode(callSuper = false)
public class Grader {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    @Column(name = "grader_id", length = 50, unique = true, nullable = false)
    private String graderId;

    @Column(name = "user_id", length = 50, unique = true, nullable = false)
    private String userId;

    @Column(name = "name", length = 100, nullable = false)
    private String name;

    @Column(name = "email", length = 200)
    private String email;

    @Column(name = "phone", length = 50)
    private String phone;

    @Column(name = "department_id", length = 50)
    private String departmentId;

    @Column(name = "specialties", columnDefinition = "TEXT")
    private String specialties; // JSON数组格式

    @Enumerated(EnumType.STRING)
    @Column(name = "experience_level", length = 20)
    private ExperienceLevel experienceLevel;

    @Column(name = "max_workload")
    private Integer maxWorkload;

    @Column(name = "current_workload")
    private Integer currentWorkload;

    @Column(name = "availability_status", length = 20)
    private String availabilityStatus;

    @Column(name = "quality_score", precision = 3, scale = 2)
    private Double qualityScore;

    @Column(name = "average_completion_time")
    private Integer averageCompletionTime; // 平均完成时间（分钟）

    @Enumerated(EnumType.STRING)
    @Column(name = "status", length = 20)
    private GraderStatus status;

    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    @Column(name = "update_time", nullable = false)
    private LocalDateTime updatedTime;

    // 扩展字段
    @Column(name = "academic_title", length = 50)
    private String academicTitle; // 职称

    @Column(name = "specialization_areas", columnDefinition = "TEXT")
    private String specializationAreas; // 专业领域详细描述

    @Column(name = "years_of_experience")
    private Integer yearsOfExperience;

    @Column(name = "total_tasks_completed")
    private Integer totalTasksCompleted;

    @Column(name = "total_questions_graded")
    private Integer totalQuestionsGraded;

    @Column(name = "average_quality_score", precision = 3, scale = 2)
    private Double averageQualityScore;

    @Column(name = "reliability_score", precision = 3, scale = 2)
    private Double reliabilityScore; // 可靠性评分

    @Column(name = "efficiency_score", precision = 3, scale = 2)
    private Double efficiencyScore; // 效率评分

    @Column(name = "preferred_subjects", columnDefinition = "TEXT")
    private String preferredSubjects; // 偏好科目（JSON数组）

    @Column(name = "avoid_subjects", columnDefinition = "TEXT")
    private String avoidSubjects; // 避免科目（JSON数组）

    @Column(name = "max_difficulty_level")
    private Integer maxDifficultyLevel; // 能处理的最大难度等级

    @Column(name = "work_schedule", columnDefinition = "TEXT")
    private String workSchedule; // 工作时间安排（JSON格式）

    @Column(name = "last_active_time")
    private LocalDateTime lastActiveTime;

    @Column(name = "certifications", columnDefinition = "TEXT")
    private String certifications; // 资质证书（JSON数组）

    @Column(name = "performance_notes", columnDefinition = "TEXT")
    private String performanceNotes; // 绩效备注

    @Column(name = "training_records", columnDefinition = "TEXT")
    private String trainingRecords; // 培训记录（JSON数组）

    @Column(name = "preference_config", columnDefinition = "TEXT")
    private String preferenceConfig; // 分配偏好配置（JSON格式）
}